<?php
namespace app\index\controller;

use app\Logined;
use app\model\OperaCollection;
use app\model\Opera;
use app\model\Operalog as Model;

class Operalog extends Logined
{
    public function index()
    {
        $paginate = Model::where('user_id', $this->user_id)->group('opera_id')->order('operalog_id desc')->paginate($this->param['limit'])->each(function ($item, $index){
            $item['opera_info'] = Opera::where('opera_id', $item['opera_id'])->find();
            $item['collection_count'] = OperaCollection::where('opera_id', $item['opera_id'])->count();
            $item['last_num'] = OperaCollection::where('opera_collection_id', $item['opera_collection_id'])->value('sort_num');
        });
        return $this->success('请求成功', [
            'paginate' => $paginate
        ]);
    }



}
